package gui;

import gui.BuildingSketchView.GraphicBuildingList;


import java.util.ArrayList;
import java.util.Observable;

import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
/**
 * Class is depreciated and no longer used.
 * @author Chrystopher
 *
 */
public class SelectionView extends JInternalFrame implements IView{
	
	private JTree tree;
	private DefaultMutableTreeNode rootNode;
	private ArrayList<DefaultMutableTreeNode> majorStyleSubNodes;
	
	public SelectionView(GraphicBuildingList buildings){
		
		/*
		 * Selon le tutoriel:
		 * http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JTree.html
		 * JTree de Swing
		 */
		rootNode = new DefaultMutableTreeNode("Major Markets & Artists");
		System.out.println(buildings.getLength());
		majorStyleSubNodes = new ArrayList<DefaultMutableTreeNode>();
		
		for (int i = 0; i < buildings.getLength(); i++) {
			majorStyleSubNodes.add(new DefaultMutableTreeNode(buildings.getBuilding(i).toString()));
			for (int j = 0; j < buildings.getBuilding(i).getWindows().getLength(); j++) {
				majorStyleSubNodes.get(i).add(new DefaultMutableTreeNode(buildings.getBuilding(i).getWindows().getWindow(j).toString()));
			}
		}
		
		display();
	}

	@Override
	public void update(Observable o, Object arg) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void display() {
		for (int i = 0; i < majorStyleSubNodes.size(); i++) {
			rootNode.add(majorStyleSubNodes.get(i));
		}
		setTitle("Selection Pane");
		tree = new JTree(rootNode);
		//setSize(100, 300);
		getContentPane().add(new JScrollPane(tree));
		setVisible(true);
	}

}
